package com.ids.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class DbManager {
	
	public  Connection getConnection() {
		Connection myConnection = null;
				try {
					Class.forName("com.mysql.jdbc.Driver");
					String url = "jdbc:mysql://10.16.20.151:3306/attendancetracker";
				    String password = "login@123";
//					String url = "jdbc:mysql://10.16.20.12:3306/attendancetracker";
//					String password = "password";
					String username = "root";
					myConnection = DriverManager.getConnection(url, username, password);
				} catch (Exception e) {
					e.printStackTrace();
					System.err.println("Got an exception while creating a connection Object! ");
					System.err.println(e.getMessage());
				}
			
		return myConnection;
	}
	public static void closeResultSet(ResultSet rs) {
		if (null != rs) {
			try {
				rs.close();
			} catch (Exception e) {
				e.printStackTrace();
				System.err.println("Got an exception while closing the resultset object! ");
				System.err.println(e.getMessage());
			}
		}
	}

	public static void closeConnection(Connection conn) {
		if (null != conn) {
			try {
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
				System.err.println("Got an exception while closing the resultset object! ");
				System.err.println(e.getMessage());
			}
		}
	}
}
